package ctrl_touriste;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import royaume.RoyaumeImpl;
import royaume.RoyaumeManager;

/**
 * Servlet implementation class ServletClassement
 */
public class ServletClassement extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	private List<RoyaumeImpl> listeRoy;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public ServletClassement() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		listeRoy = new ArrayList<RoyaumeImpl>(RoyaumeManager.tousLesRoyaumes());
		Collections.sort(listeRoy);
		request.setAttribute("listeRoy", listeRoy);
		request.setAttribute("content", "classement.jsp");
		getServletContext().getRequestDispatcher("/ServletAccueil")
		.forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
